package com.example.milimili;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

public class FragmentAdapter extends FragmentStateAdapter {

    public FragmentAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override

    public Fragment createFragment(int position) {
        NewsFragment newsFragment=new NewsFragment();
        String tabName=GridActivity.mUserList.get(position);
        newsFragment.category=tabName;
        return newsFragment;
    }

    @Override
    public int getItemCount() {
        return getTabNum();
    }

    public static int getTabNum(){
        return GridActivity.mUserList.size();
    }
}
